package com.saltlux.tdd.algorithm;

import org.junit.Assert;
import org.junit.Test;

public class MinimumFinderTester {
	@Test
	public void testFindMinimumIndex() {
		MinimumFinder finder = new MinimumFinder();
		int[] target = new int[] { 3, 1, 2 };
		int minimumIndex = finder.findIndexOfMinimumValue(target);

		Assert.assertEquals(1, minimumIndex);
	}

	@Test
	public void testFindMinimumIndex1() {
		MinimumFinder finder = new MinimumFinder();
		int[] target = new int[] { 6, 7, 9, 24, 3, 1, 2 };
		int minimumIndex = finder.findIndexOfMinimumValue(target);

		Assert.assertEquals(5, minimumIndex);
	}

	@Test
	public void testFindMinimumIndex2() {
		MinimumFinder finder = new MinimumFinder();
		int[] target = new int[] { 3, 2, 1 };
		int minimumIndex = finder.findIndexOfMinimumValue(target);

		Assert.assertEquals(2, minimumIndex);
	}

	@Test
	public void testFindMinimumIndex3() {
		MinimumFinder finder = new MinimumFinder();
		int[] target = new int[] { 1, 4, 2, 8 };
		int from = 1;
		int minimumIndex = finder.findIndexOfMinimumValue(target, from);

		Assert.assertEquals(2, minimumIndex);
	}
	
	@Test
	public void testFindMinimumStringIndex() {
		MinimumFinder finder = new MinimumFinder();
		int minimumIndex = finder.findIndexOfMinimumValue(new String[]{"b", "a", "c"}, 0);

		Assert.assertEquals(1, minimumIndex);
	}
	
	@Test
	public void testFindMinimumDoubleIndex(){
		MinimumFinder finder = new MinimumFinder();
		int minimumIndex = finder.findIndexOfMinimumValue(new Double[]{2.4,1.3,2.2}, 0);

		Assert.assertEquals(1, minimumIndex);
	}
}
